package math;

public class Part extends Number {

	protected double value;
	
	public Part() {
		this.value = 0;
	}
	
	public Part(double value){
		if(!Part.check(value)){
			throw new IllegalArgumentException("Part value must be between 1 and 0 but was given "+value);
		}
		this.value = value;
	}

	public static boolean check(double value) {
		return value >= 0 && value <= 1;
	}

	@Override
	public double doubleValue(){
		return value;
	}

	@Override
	public float floatValue(){
		return (float)value;
	}

	@Override
	public int intValue(){
		return (int)Math.round(value);
	}

	@Override
	public long longValue() {
		return (long)Math.round(value);
	}

}
